<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			input {
				border: none;
				margin-right: 8px;
			}

			input:focus {
				outline: none;
			}
		</style>
	</head>
	<body>
		<input placeholder="输入验证码" /><button>发送验证码</button>
		<script type="text/javascript">
			
			var btn = document.querySelector("button");
			btn.addEventListener('click', function() {
				var time = 10;
				btn.disabled = true;
				var intervalID = setInterval(function() {
					if (time == 0) {
						clearInterval(intervalID);
						btn.disabled = false;
						btn.innerHTML = "发送验证码";
					} else {
						btn.innerHTML = time + "s后重新获取";
						time--;
						time = time < 10 ? "0" + time : time;
					}

				}, 1000)
			})
		</script>
	</body>
</html>
